"""
Event type string used in BQ for redis.pubsub channel.
"""

from enum import Enum

EVENT_RQ = "rq_"  # 查询请求，可与其它联合使用：EVENT_RQ+EVENT_ORDER 生成 rq_eOrder.
EVENT_TIMER = "eTimer"  # noqa

EVENT_TICK = "eTick."
EVENT_TRADE = "eTrade."
EVENT_ORDER = "eOrder."
EVENT_PARK_ORDER = 'eParkOrder.'
EVENT_POSITION = "ePosition."
EVENT_ACCOUNT = "eAccount."
EVENT_CONTRACT = "eContract."
EVENT_LOG = "eLog"
EVENT_POSITION_DETAIL = "ePositionDetail."
EVENT_MD_LOGIN = 'eMDLogin.'
EVENT_TD_LOGIN = 'eTDLogin.'
EVENT_MD_CONNECTED = 'eMDConnected.'
EVENT_TD_CONNECTED = 'eTDConnected.'
EVENT_INSTRUMENT = "eInstrument."
EVENT_INSTRUMENT_OK = "eInstrumentOK."
EVENT_POSITION_DETAIL_OK = "ePositionDetailOK."
EVENT_POSITION_OK = "ePositionOK."
EVENT_INSTRUMENT_STATUS = 'eInstrumentStatus.'
EVENT_ACCOUNT_OK = 'eAccountOK.'
EVENT_ORDER_OK = "eOrderOK."
EVENT_FUTURE = 'eFuture.'

EVENT_STRA = 'eStrategy.'
EVENT_STRATEGY = 'eStrategy.'

EVENT_STRA_SIGNAL = 'eStraSignal.'
EVENT_STOP_ORDER = "eStopOrder."
EVENT_SUBSCRIBE = 'eSubscribe.'
EVENT_UNSUBSCRIBE = 'eUnSubscribe.'


class EventType(Enum):
    INSTRUMENT = "inst."
    FUTURE = "future."
    OPTION = "option."
    ORDER = "order."
    PARKORDER = "park_order."
    TRADE = "trade."
    ACCOUNT = "acc."
    POSITION = "position."
    POSITIONDETAIL = "position_detail."
    STRATEGY = "strategy."
    STRASIGNAL = "eStraSignal."
    TICK = "Tick."  # 后加 instrument id, publish 时的 channel
    BAR = "Bar."

    SUBSCRIBEINSTRUMENT = "Subscribe."
    REQSUBINST = "ReqSubInst."
    REQORDERINSERT = "ReqOrderInsert."
    REQUNSUBINST = "ReqUnSubInst."
    RQACC = "ReqQryAccount."
    RQTRADE = "ReqQryTrade."
    RQORDER = "ReqQryOrder."
    RQPOSITION = "ReqQryPosition."
    RQPOSITIONDETAIL = "ReqQryPositionDetail."

    # # PUBLISH<=>SUBSCRIBE 用作channel
    CTPWORK = "CTPWORK"  # msg:StartQuote,StopQuote,StartTrade,StopTrade
    EVENT_MD_CONNECT_STATUS = "QuoteConnected"  # true or false  1 or 0
    EVENT_MD_LOGIN_STATUS = "QuoteLogin"  # true or false
    EVENT_TD_CONNECT_STATUS = "TradeConnected"
    EVENT_TD_LOGIN_STATUS = "TradeLogin"
    # # ctp redis 中数据库
    COMMONDB = 0  # 通用数据库
    QUOTEDB = 1  # 市场行情数据库
    TRADEDB = 2  # 交易数据库
    ACCOUNTDB = 10  # 账户数据库
    STRATEGYDB = 3  # 策略数据库

    EVENT_RQ = "rq_"  # 查询请求，可与其它联合使用：EVENT_RQ+EVENT_ORDER 生成 rq_eOrder.
    EVENT_TIMER = "eTimer"  # noqa
    EVENT_TICK = "eTick."
    EVENT_TRADE = "eTrade."
    EVENT_ORDER = "eOrder."
    EVENT_PARK_ORDER = "eParkOrder."
    EVENT_POSITION = "ePosition."
    EVENT_ACCOUNT = "eAccount."
    EVENT_CONTRACT = "eContract."
    EVENT_LOG = "eLog"
    EVENT_POSITION_DETAIL = "ePositionDetail."
    EVENT_MD_LOGIN = "eMDLogin."
    EVENT_TD_LOGIN = "eTDLogin."
    EVENT_MD_CONNECTED = "eMDConnected."
    EVENT_TD_CONNECTED = "eTDConnected."
    EVENT_INSTRUMENT = "eInstrument."
    EVENT_INSTRUMENT_OK = "eInstrumentOK."
    EVENT_POSITION_DETAIL_OK = "ePositionDetailOK."
    EVENT_POSITION_OK = "ePositionOK."
    EVENT_INSTRUMENT_STATUS = "eInstrumentStatus."
    EVENT_ACCOUNT_OK = "eAccountOK."
    EVENT_ORDER_OK = "eOrderOK."
    EVENT_FUTURE = "eFuture."
    EVENT_STRA = "eStrategy."
    EVENT_STRATEGY = "eStrategy."
    EVENT_STRA_SIGNAL = "eStraSignal."
    EVENT_STOP_ORDER = "eStopOrder."
    EVENT_SUBSCRIBE = "eSubscribe."
    EVENT_UNSUBSCRIBE = "eUnSubscribe."

